package DAO;

import metier.RecompenseFilm;

public class DAORecompenseFilmJPA extends DAORecompenseJPA implements DAORecompenseFilm{

	private static DAORecompenseFilmJPA instance=null;
	
	private DAORecompenseFilmJPA() {}
	
	public static DAORecompenseFilmJPA getInstance() {
		if(instance == null)
			instance = new DAORecompenseFilmJPA();
		return instance;
	}
	
	@Override
	public RecompenseFilm get(int id) {
		RecompenseFilm recompense = DAOJPA.getManager().find(RecompenseFilm.class, id);
		return recompense;
	}


	@Override
	public void save(RecompenseFilm recompense){
		if(recompense.getId() != -1)
			throw new IllegalArgumentException("Recompense d�ja enregistr�e");

		DAOJPA.getManager().persist(recompense);
		DAOJPA.commit();
	}


}
